﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using eStore.ViewModels;
using eStore.Models;

namespace MVCStore.Controllers
{
    public class HomeController : Controller
    {
        private IProductRepository productRepo = null;

        public HomeController():this(new ProductRepository()) { 
        
        }

        public HomeController(IProductRepository productRep) {
            productRepo = productRep;        
        }

        //
        // GET: /Home/
        public ActionResult Index()
        {
            var top5RatedProduct = productRepo.GetTop5RatedProduct();
            var topLatestProduct = productRepo.GetTopLatestProduct();

            HomeIndexViewModel oViewModel = new HomeIndexViewModel()
                                                                {
                                                                    PageTitle = "Welcome to eStore",
                                                                    TopRatedCount = 5,
                                                                    TopRatedProducts = top5RatedProduct,
                                                                    TopLatestProduct = topLatestProduct
                                                                };
            return View(oViewModel);
        }

        [ActionName("About-Us")]
        public ActionResult AboutUs() {

            return View();
        }

        
    }
}
